Sentiment Analysis on Swiss Newspaper Jupyter Notebook

Giorgio Bakhiet Derias I3a, Bachelorarbeit

The aim of this notebook is to make an analysis of the sentiment about the different newspapers that can be read in Switzerland.

Setup

Install from requirements

In order to work I first need to install the libraries from which I will then import what I need. I created a text file called requirementsNewspaper, in which I saved all the libraries I used. The usefulness of this file is when I move to a new environment, installing all packages at once by simply typing:

Imports


Reload Model

Find the bug!

First text

Title with source at the end, without dot at end. = NEGATIVE

Title with source at the end, with dot at end. = Positive

Title without source, without dot = positive

Title without source , with dot at end. = positive +

Title+description, with - source = negative

Title+descritpion, without "- source" = positive

Second text

The dot at the end of the sentence changes the meaning of the sentence!

If I remove the source in the sentence I have better accuracy!

Adding the dot and removing the source improve accuracy

Newspaper

Clean the source

Load the dataset

Prediction on newspaper dataset

Count predictions

Remove duplicates

Clean date column

Plot the data

Now that the data has been imported, predicted and cleaned I can start to analyse it, to do this I will use plolty. In order to display the data correctly I will first have to normalise it, I have written two functions for this purpose.

Plot of sentiment positive vs negative

Plot all newspaper positive vs negative per total count

Plot of all newspaper positive vs negative

Plot top 10 positive vs top 10 negative

Plot pro category positive vs negative

Plot pro category of the top 3 newspaper

I will only consider the three largest newspapers by number of article

For visualisation I create a minus value for "negative" values

Plot spider category of a single newspaper

Def for plotting SPIDER

Plot spider

Plot in Time

Plot newspaper in time

Plot category in time

Export